#ifndef _STDARG_H_
#define _STDARG_H_

/*
 * Theese are tested on x86. Probably they wont work on any other architecture.
 * It depends on how does gcc put the arguments of a function.
 * Eg. on some archs, maybe the arguments are given throug registers.
 * IIRC it works like this on the MIPS R3000A, the Play Station processor.
 */
#if ARCH == x86

typedef unsigned char *va_list;

#define	STACKITEM	int
#define	VA_SIZE(TYPE)	((sizeof(TYPE) + sizeof(STACKITEM) - 1)	& ~(sizeof(STACKITEM) - 1))
#define	va_start(AP, LASTARG)	(AP = ((va_list) &(LASTARG) + VA_SIZE(LASTARG)))
#define va_end(AP)	/* nothing */
#define va_arg(AP, TYPE)	(AP += VA_SIZE(TYPE), *((TYPE *) (AP - VA_SIZE(TYPE))))

#endif	/* ARCH == x86 */

#endif
